﻿<!DOCTYPE html>
<html ng-app>
  <head>
    <meta charset="UTF-8">
    <title>基本构造</title>
  
      <script src="../JS/angular.min.js"></script>

    <script type="text/javascript">

        //// 直接创建
        //function MyController($scope) {
        //    $scope.text = "234";
        //    $scope.user = {
        //        Name: 'test',
        //        Age: 18
        //    }
        //}
         // 通过数组的方式进行创建
        var MyController = ['$scope', '$timeout', function ($scope, $timeout) {
            $scope.user = {
                Name: 'test',
                Age: 18
            };
            $timeout(function () {
                alert('123');
            }, 1000);
        }];

         // 通过inject方式创建
        var MyController = function ($scope, $timeout) {
            $scope.user = {
                Name: 'test',
                Age: 18
            };
            $timeout(function () {
                alert('123');
            }, 1000);
        };
        mycontroller.$inject = ['$scope', '$timeout'];

    </script>
  </head>
<body >
    <div >
        <div ng-controller="MyController">
          <p>Name:{{user.Name}}</p>
          <p>Age:{{user.Age}}</p>
      </div>
    
    </div>
      


  </body>
</html>
